package com.dhz.wlzs.app.controller;

import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/proto")
public class ProtobufController {

	@RequestMapping(value = "/w", method = RequestMethod.POST)
	public ResponseEntity<UserProto.User> protoWrite1(RequestEntity<UserProto.User> requestEntity) {
		UserProto.User user = requestEntity.getBody();
		System.out.println("user:\n" + user);
		return ResponseEntity.ok(user);
	}

	@RequestMapping("/r")
	public ResponseEntity<UserProto.User> protoRead() {
		return ResponseEntity.ok(UserProto.User.newBuilder().setId(1).setName("rose").build());
	}
}
